package com.isoft.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.isoft.entity.User;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;
import org.springframework.stereotype.Repository;

import java.util.List;


@Mapper
@Repository
public interface UserMapper extends BaseMapper<User> {
    @Results({
            @Result(property = "userRole",column = "id",
                    one = @One(select = "com.isoft.mapper.UserRoleMapper.selectRoleByUserId",
                            fetchType = FetchType.DEFAULT))
    })
    @Select("select * from user where username=#{username} and password=#{password}")
    User login(User user);
    @Select("SELECT * from user  where username=#{username}")
    User register(User user);
   // @Select("select * from user where username=#{username} and password=#{password}")
   // User login1(User user);
    @Select("select * from user where username=#{username} and password=#{password}")
    User loginPermission(User user);
    @Select("SELECT * from user where username=#{username}")
    User permission(String username);

    @Update("update user set gender=#{gender}, phone=#{phone}, address=#{address} where jobnum=#{jobnum}")
    void update(User user);
    @Delete(("delete from user where jobnum=#{jobnum}"))
    void delete(String jobnum);
    @Select("select * from user")
    List<User> getAllUsers();
    @Select("select * from user where jobnum=#{jobnum}")
    User select(String jobnum);
    @Select("select * from user where jobnum=#{jobnum}")
    User haveUser(User user);
    @Select("select email from user where jobnum=#{jobnum}")
    String findEmail(String jobnum);


}